class Person {

}


const p1: Person = new Person()

type MYPerson = InstanceType<typeof Person>
const p2: MYPerson = new Person()

// 构造函数的例子
// InstanceType构造函数创建出来的实例对象的类型
function factory<T extends new (...args: any) => any>(ctor: T): InstanceType<T> {
    return new ctor()
}
const fa = factory(Person)


type MyInstanceType<T extends new (...args: any) => any> = T extends new (...args: any) => infer R ? R : never
function factory2<T extends new (...args: any) => any>(ctor: T): MyInstanceType<T> {
    return new ctor()
}
const fa2 = factory2(Person)


export { }